/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2024-03-23
 * Time: 19:12
 */
public class Test {
    public static void main(String[] args) {
        Object locker = new Object();

        Thread t1 = new Thread(() -> {
          synchronized(locker) {
              System.out.println("t1 wait之前");
              try{
                  locker.wait();
              } catch (InterruptedException e){
                  e.printStackTrace();
              }
              System.out.println("t1 wait之后");

          }
        });

        Thread t2 = new Thread(() -> {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            synchronized(locker) {
                System.out.println("t2 notify之前");
                locker.notify();
                System.out.println("t2 notify之后");


            }
        });

        t1.start();
        t2.start();
    }
}
